<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{margin:0;padding:0}
body{background:#c7edcc;height:2000px;}
#myDiv{width:200px;height:200px;border:1px solid #000;}

</style>

<script src="eventObject.js" type="text/javascript"></script>
</head>

<body>
	
    <script> 
	
		var eventInstance=new EventFunction();
		
		eventInstance.addHandler(window, 'load', function(event){
			
			var script=document.createElement('script');
			
			//先执行一次							//IE10-和Opera支持 readystatechange事件会绑定好几次(即为readystatechange添加好几次事件处理程序,函数会执行好几次)
			eventInstance.addHandler(script, 'readystatechange', function(event){
		
				var target=eventInstance.getTarget(event);
				
				console.log(target.readyState);
				
				if(target.readyState == 'loaded' || target.readyState == 'complete'){
					
					eventInstance.removeHandler(target, 'readystatechange', arguments.callee);
					
					console.log('script loaded');	
				}
			});
			
			//在执行这里
			script.src='clientDetection.js';
			
			document.body.appendChild(script);
			
		});
		
    </script>
    
</body>
</html>
